package com.magic.babyphotos;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;

public class BaseActivity extends Activity implements OnClickListener, OnTouchListener
{
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
//		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
	}
	
	protected void changeAlpha(View v, int action)
    {
        if(action == MotionEvent.ACTION_DOWN)
        {
            if(((ImageView)v).getDrawable() != null)
            {
                ImageView img = (ImageView)v;
                Drawable alphaDrawable = img.getDrawable();
                alphaDrawable.setAlpha(200);
                img.setImageDrawable(alphaDrawable);
            }
        }
        else if(action == MotionEvent.ACTION_UP | action == MotionEvent.ACTION_OUTSIDE)
        {
            if(((ImageView)v).getDrawable() != null)
            {
                ImageView img = (ImageView)v;
                Drawable alphaDrawable = img.getDrawable();
                alphaDrawable.setAlpha(255);
                img.setImageDrawable(alphaDrawable);
            }
        }
    }
	
	@Override
    public boolean onTouch(View v, MotionEvent event)
    {
        switch(v.getId())
        {
	        case R.id.bt_back:
	        {
	            changeAlpha(v, event.getAction());
	            break;
	        }
        }
        
        return false;
    }
	
	@Override
    public void onClick(View v)
    {
        switch(v.getId())
        {
            case R.id.bt_back:
            {
                this.finish();
                break;
            }
        }
        
    }
	
}
